@@ -18,4 +18,18 @@ module JobsHelper |
||
18 | 18 |
'in ' + distance_of_time_in_words(time, now) |
19 | 19 |
end |
20 | 20 |
end |
21 |
+ |
|
22 |
+ # Given an queued job, parse the stored YAML to retrieve the ID of the Agent |
|
23 |
+ # meant to be ran. |
|
24 |
+ # |
|
25 |
+ # Can return nil, or an instance of Agent. |
|
26 |
+ def agent_from_job(job) |
|
27 |
+ begin |
|
28 |
+ Agent.find_by_id(YAML.load(job.handler).args[0]) |
|
29 |
+ rescue ArgumentError |
|
30 |
+ # We can get to this point before all of the agents have loaded (usually, |
|
31 |
+ # in development) |
|
32 |
+ nil |
|
33 |
+ end |
|
34 |
+ end |
|
21 | 35 |
end |
@@ -20,7 +20,7 @@ |
||
20 | 20 |
</tr> |
21 | 21 |
|
22 | 22 |
<% @jobs.each do |job| %> |
23 |
- <% agent = Agent.find_by_id(YAML.load(job.handler).args[0]) %> |
|
23 |
+ <% agent = agent_from_job(job) %> |
|
24 | 24 |
<tr> |
25 | 25 |
<td><%= status(job) %></td> |
26 | 26 |
<td><%= agent ? link_to(agent.name, agent_path(agent)) : "(deleted)" %></td> |